﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
using System.Drawing;
using System.Net.Mail;
using System.Web.Services;
using AjaxControlToolkit;
using System.IO.MemoryMappedFiles;

public partial class admin_rent_client_update : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["email"] == null)
        {
            Response.Redirect("sessiont.aspx");
        }
        int s = 0;
        Label7.Text = s.ToString();
        Label2.Text = Session["email"].ToString();



        if (Page.IsPostBack)
        {
        }
        else
        {

            SqlConnection conn = null;
            conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
            conn.Open();
            SqlCommand scmd = new SqlCommand("SELECT * FROM client_add_rent where c_id='" + Session["c_id"] + "'", conn);

            SqlDataReader dr = scmd.ExecuteReader();
            if (dr.Read())
            {



                txtmname.Text = dr[5].ToString();
                txtname1.Text = dr[6].ToString();
                txthno.Text = dr[8].ToString();
                txtcity.Text = dr[9].ToString();
                txtstreet.Text = dr[11].ToString();
                txtssn.Text = dr[12].ToString();
                txtcountry.Text = dr[14].ToString();
                txtemail.Text = dr[15].ToString();
                txtphno.Text = dr[16].ToString();
                TextBox3.Text = dr[17].ToString();
                TextBox4.Text = dr[18].ToString();

                TextBox7.Text = dr[19].ToString();

                TextBox9.Text = dr[21].ToString();

                TextBox11.Text = dr[22].ToString();
                TextBox12.Text = dr[23].ToString();

                TextBox14.Text = dr[24].ToString();


                TextBox10.Text = dr[25].ToString();
                TextBox13.Text = dr[26].ToString();

                txtcatname.Text = dr[27].ToString();

                Label8.Text = Session["c_id"].ToString();





            }


            dr.Close();
        }
    }
    protected void Save_Click(object sender, EventArgs e)
    {
        //string field = txtfield.Text + DropDownList10.SelectedValue;


        //string p_size = TextBox11.Text + DropDownList7.SelectedValue;

        SqlConnection conn = null;
        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn.Open();

        SqlCommand cm1 = new SqlCommand("update client_add_rent set client_fullname='" + txtmname.Text + "'  , property_type='" + txtname1.Text + "', house_no='" + txthno.Text + "', city='" + txtcity.Text + "',  street='" + txtstreet.Text + "',  ssn='" + txtssn.Text + "',zip='" + txtzip.Text + "', country='" + txtcountry.Text + "', email_id='" + txtemail.Text + "', phone='" + txtphno.Text + "', room_no='" + TextBox3.Text + "',  floor='" + TextBox4.Text + "', ac='" + DropDownList16.Text + "', parking='" + TextBox7.Text + "', elevator='" + DropDownList17.SelectedValue + "', price='" + TextBox9.Text + "', prop_size='" + DropDownList7.Text + "',adding_by='" + Session["email"] + "', size_no='" + TextBox11.Text + "',entry_date='" + TextBox12.Text + "', roommates='" + DropDownList8.SelectedValue + "', no_roommates='" + TextBox14.Text + "',gaurantee='" + DropDownList10.SelectedValue + "', voucher='" + DropDownList9.SelectedValue + "',smoke='" + DropDownList11.SelectedValue + "',animal='" + DropDownList12.SelectedValue + "', prop_cond='" + DropDownList13.SelectedValue + "', balcony='" + DropDownList14.SelectedValue + "', available='" + TextBox10.Text + "',comments='" + TextBox13.Text + "',choose_cat='" + ddlcategory.SelectedValue + "',c_cat='" + "0" + "',category='" + txtcatname.Text + "',safe_room='" + TextBox5.Text + "' where c_id='" + Session["c_id"] + "'", conn);
        cm1.ExecuteNonQuery();
        Response.Redirect("partner_update_client_conf.aspx");
        conn.Close();
    }
    protected void Cancel_Click(object sender, EventArgs e)
    {

    }
    protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void LinkButton1_Click(object sender, System.EventArgs e)
    {
        Session.Abandon();
          Response.Redirect("../partner.aspx");
    }
}